<?php
class Page extends Tatu {
	
	function Page() {
		parent::Tatu();
		$this->database();
		$this->lib('message', 'session');
	}
	
	function index() {	
		$this->lib('pagination');
		$total = $this->db->find_var("select count(*) from page");
		if( $total <= 0 ) {
			$this->view('manage/empty_article_list');	
			return;
		}
		$config = array(
			'total_row' => $total,
			'url'		=> site_url('manage/pages')
		);
		$this->pagination->init( $config );
		$page_list = $this->db->find(
			"select * from page limit ". $this->pagination->start_row .", 10");
		$this->set('page_list', $page_list);
		$this->view('manage/page/page_list');
	}
	
	function init_update($id) {
		$page = $this->db->find_row("select * from page where id=$id");
		
		$this->set('page', $page);
		$this->view('manage/page/page_update');
	}
	
	function update() {
		extract($_POST);
		$data = array(
			'content' => $content
		);
		
		$this->db->update('page', $data, "id=$page_id");
		
		$this->message->set('更新文章成功');
		$this->view('manage/page/page_fo');
	}
	
}
?>